home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 015 / fflfnp.arc / FFLFNP.ASM < prev    next >
Encoding:
Assembly Source File  |  1987-03-12  |  8.4 KB  |  164 lines

  1. ; FFLFNP.ASM    Version 1.0
  2.  
  3. ;  Version 1.0 adds NOPRINT function to Version 5.0 of FFLF.COM
  4. ;    to create new program.
  5.  
  6. ; Memory-resident program to send form feed and line feed 
  7. ;    characters to printer.
  8.  
  9. ;       Alt-* [PrtSc]  =  form feed
  10. ;       Alt-/          =  line feed
  11.  
  12. ; Disables Shift-PrtSc and Ctrl-PrtSc if printer is not ready.
  13.  
  14. ; Checks printer status, beeps if printer not ready.
  15. ; Includes installation messages.
  16.  
  17. ; Checks for prior installation by looking for four words of code.
  18. ; Uses interrupt 10h to generate beep.
  19.  
  20. ; Written in CHeap ASseMbler format by :
  21. ;       L. R. Holliday
  22. ;       Vista Chemical Company
  23. ;       P. O. Box 500
  24. ;       Ponca City, Oklahoma 74601
  25. ;       (405) 767-6326
  26.  
  27. fflfnp        proc      far
  28.               jmp       set_up         ; Jump to initialize
  29. addr_bx       ds        2,0            ; Space to store KBINT offset
  30. addr_es       ds        2,0            ; Space to store KBINT segment
  31. flag          db        0fh
  32. new_kbint     sti                      ; Interrupts on
  33.               push      ax             ; Store registers
  34.               push      dx
  35.               push      bx
  36.               push      cx
  37.               mov       ah,02          ; Get shift state
  38.               int       16h            ;    through BIOS
  39.               test      al,07          ; Is Ctrl or Shift key pressed ?
  40.               jnz       noprint        ; If so, jump to noprint
  41.               test      al,08          ; Is Alt key pressed ?
  42.               jz        exit           ; If not, jump to exit
  43.               in        al,60h         ; Get key scan code
  44.               cmp       al,37h         ; Is it * [PrtSc] Key ?
  45.               jz        formfeed       ; If so, jump to formfeed
  46.               cmp       al,35h         ; Is it / Key ?
  47.               jz        linefeed       ; If so, jump to linefeed
  48.               jmps      exit           ; If none of above, jump to exit
  49. noprint       in        al,60h         ; Get key scan code
  50.               cmp       al,37h         ; Is it * [PrtSc] Key ?
  51.               jnz       exit           ; If not, jump to exit
  52.               mov       dx,0000        ; Select printer 1
  53.               mov       ah,02          ; check printer status
  54.               int       17h
  55.               cmp       ah,90h         ; is printer on-line ?
  56.               jnz       beep           ; if not, then beep and reset keyboard
  57.               jmps      exit           ; if so, then exit to DOS PrtSc function
  58. formfeed      mov       dx,0000        ; Select printer 1
  59.               mov       ah,02          ; check printer status
  60.               int       17h
  61.               cmp       ah,90h         ; is printer on-line ?
  62.               jnz       beep           ; if not, then beep and reset keyboard
  63.               mov       ax,000Ch       ; Put Formfeed character in AL
  64.               int       17h            ; Send to printer
  65.               jmps      kb_reset       ; Jump to KeyBoard Reset
  66. linefeed      mov       dx,0000        ; Select printer 1
  67.               mov       ah,02          ; check printer status
  68.               int       17h
  69.               cmp       ah,90h         ; is printer on-line ?
  70.               jnz       beep           ; if not, then beep and reset keyboard
  71.               mov       ax,000Ah       ; Put Linefeed character in AL
  72.               int       17h            ; Send to printer
  73.               jmps      kb_reset       ; Jump to KeyBoard Reset
  74. beep          mov       ah,0eh         ; Set for write to screen
  75.               mov       cx,0001        ; Number of characters to write
  76.               mov       al,07          ; Beep character
  77.               int       10h            ; Send to screen
  78. kb_reset      in        al,61h         ; These instructions reset the
  79.               mov       ah,al          ;     keyboard
  80.               or        al,80h         ;       ......
  81.               out       61h,al         ;       ......
  82.               mov       al,ah          ;       ......
  83.               out       61h,al         ;       ......
  84.               cli                      ; Turn interrupts off
  85.               mov       al,20h         ; Send End-of-Interrupt
  86.               out       20h,al         ;      signal
  87.               pop       cx             ; Restore registers
  88.               pop       bx
  89.               pop       dx
  90.               pop       ax
  91.               iret                     ; Return to interrupted program
  92. exit          pop       cx             ; Restore registers
  93.               pop       bx
  94.               pop       dx
  95.               pop       ax
  96.               seg       cs             ; cs:
  97.               jmpf      addr_bx        ; Return to old kbint
  98. set_up        mov       ah,30h         ; Check DOS Version
  99.               int       21h
  100.               cmp       al,2           ; Is it 2 or higher ?
  101.               jae       check          ; If so, check for prior installation
  102.               mov       dx,offset(err_msg2)
  103.               jmps      msg_exit       ; If not, issue error message
  104. check         mov       dx,offset(new_kbint)  ; Offset to begin search
  105.               mov       ax,cs          ; DS:SI points to destination
  106.               mov       es,ax          ; ES:DI points to source
  107. nextseg       dec       ax             ; Search previous segment
  108.               mov       ds,ax          ; Load new segment to search
  109.               mov       si,dx          ; Point to beginning of string
  110.               mov       di,dx          ; Point to beginning of string
  111.               mov       cx,0004h       ; Four words must match
  112.               cld                      ; Clear DF for autoincrement
  113.               repz                     ; Repeat until zero
  114.               cmpsw                    ; Compare words
  115.               jnz       notfound       ; If no match, keep trying
  116. ; If found, check to see if this is a local copy, rather than installed
  117.               cmpb      flag,0fh       ; Is this installed copy ?
  118.               jnz       installed      ; If installed, skip installation
  119. notfound      cmp       ax,0001h       ; Stop searching at low memory
  120.               jnz       nextseg        ; Keep trying if not
  121. install       seg       cs             ; cs:
  122.               movb      flag,00h       ; Set installation byte
  123.               mov       AX,3509h       ; Get BIOS KBINT address through
  124.               int       21h            ;     DOS GET_VECTOR service
  125.               seg       cs             ; cs:
  126.               mov       addr_bx,bx     ; Store offset and segment
  127.               seg       cs             ; cs:
  128.               mov       addr_es,es     ;      in spaces allocated
  129.               push      cs             ; Set DS to CS
  130.               pop       ds
  131.               mov       dx,offset(new_kbint)    ; Address of new kbint
  132.               mov       ax,2509h       ; Set vector to new kbint
  133.               int       21h            ;     through DOS SET_VECTOR service
  134.               mov       dx,offset(inst_msg)
  135.               mov       ah,9           ; Display installation message
  136.               int       21h
  137.               mov       dx,offset(set_up) ; Address of end of resident code
  138.               int       27h            ; Terminate, but stay resident
  139. installed     mov       dx,offset(err_msg1)
  140. msg_exit      mov       ah,9           ; Display error message
  141.               push      cs
  142.               pop       ds             ; Restore DS
  143.               int       21h
  144.               int       20h            ; Terminate
  145. end           endp
  146.  
  147. inst_msg      db  13,10,'    FORMFEED - LINEFEED - NOPRINT  Version  1.0',13,10
  148.               db  13,10,'        by L. R. Holliday',13,10
  149.               db  13,10,'    Memory-Resident Portion Installed',13,10
  150.               db  13,10,'    Press  Alt-*   to Send FormFeed to Printer',13,10
  151.               db  13,10,'    Press  Alt-/   to Send LineFeed to Printer',13,10
  152.               db  13,10,'    Shift-PrtSc and Ctrl-Prtsc Disabled'
  153.               db  '  IF   Printer is  NOT  Ready',13,10
  154.               db  '                                       '
  155.               db  '  --',13,10,36
  156.  
  157. err_msg1      db  13,10,'    FORMFEED - LINEFEED - NOPRINT  Version  1.0',13,10
  158.               db  13,10,'        by L. R. Holliday',13,10
  159.               db  07,13,10,'    --- Already Installed ---',13,10,36
  160.  
  161. err_msg2      db  13,10,'    FORMFEED - LINEFEED - NOPRINT  Version  1.0',13,10
  162.               db  13,10,'        by L. R. Holliday',13,10
  163.               db  07,13,10,'    --- Wrong Dos Version ---',13,10,36
  164.